package com.sunyard.pcc.common.constant;

/**
 * @Author: Hewei
 * @Description:
 * @Date: Created in 14:09 2018/2/23
 */
public enum ErrorCodeEnum {

    /*--------- 100开头表示系统错误 ----------*/
    SYS_ERROR("PCL100001", "系统错误"),

    /*--------- 101开头表示通用类别 ---------*/
    SUCCESS("PCL101001", "成功"),
    FAILURE("PCL101002", "失败"),
    PARAM_ERROR("PCL101003", "参数错误"),
    PARAM_EMPTY("PCL101004", "参数为空"),
    DATABASE_DATA_ERROR("PCL101005", "数据库数据有误数据有误, 尽快勘误"),
    USER_DO_NOT_EXITS("PCL101006", "用户名不存在"),
    USER_SELECT_ERROR("PCL101007", "用户查询错误"),
    USER_IS_DISABLED("PCL101008", "用户被禁用"),
    USER_PASSWORD_NOT_FIXED("PCL101009", "密码错误"),
    INSERT_ERROR("PCL101010", "数据库插入错误"),
    ROLE_DATA_ERROR("PCL101011", "角色数据有误"),
    USER_ALREADY_EXITS_ERROR("PCL101012", "用户名已存在"),
    HAVE_NOT_LOGIN("PCL101012", "尚未登录"),
    LOGOUT_SUCCESS("PCL101013", "退出登录成功"),
    DO_NOT_HAS_PERMISSION("PCL101014", "没有访问权限"),
    LOGIN_COUNT_LIMIT_ERROR("PCL101015", "登陆次数超出限制，请五分钟后再尝试"),
    MENU_HAS_CHILD_MENU_ERROR("PCL101016", "该菜单有子菜单，无法删除"),
    MENU_HAS_CHILD_BTN_ERROR("PCL101016", "该菜单页面下有按钮，无法删除");

    private String errorCode;
    private String errorMsg;

    ErrorCodeEnum(String errorCode, String errorMsg){
        this.errorCode = errorCode;
        this.errorMsg = errorMsg;
    }


    /**
     * 根据code获取对应枚举类
     * @param errorCode
     * @return
     */
    public static ErrorCodeEnum getEnumByCode(String errorCode){
        for (ErrorCodeEnum e : ErrorCodeEnum.values()){
            if (e.getErrorCode().equals(errorCode)){
                return e;
            }
        }

        return null;
    }

    public String getErrorCode() {
        return errorCode;
    }

    public String getErrorMsg() {
        return errorMsg;
    }

}
